import cv2
import os
import math

data_dir = "/home/jh/working_data/anti-spoofing/HomeMadeData2/100_printed/train"

img_list = os.listdir( data_dir )
img_list = [ x for x in img_list if x[-4:] == '.jpg' ]
img_list = list( map( lambda s: os.path.join( data_dir , s ) , img_list ) )

for i in img_list:
    img_name = os.path.basename( i )
    img_name = os.path.join( "./tmp" , img_name )
    img = cv2.imread( i )

    h, w, _ = img.shape
    ratio = math.sqrt( (640.*480.) / (h *w) )

    img2 = cv2.resize( img, (0,0), fx = ratio , fy = ratio )

    cv2.imwrite( img_name , img2 )
